package com.netjava.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class FormatTime {
	public static void main(String args[]){
		timeFormat();
	}
	public static String timeFormat(){
		Calendar calendar=Calendar.getInstance();
		Integer year=calendar.get(Calendar.YEAR);
		Integer month=calendar.get(Calendar.MONTH)+1;
		Integer date=calendar.get(Calendar.DAY_OF_MONTH);
		Integer hour=calendar.get(Calendar.HOUR_OF_DAY);
		Integer minute=calendar.get(Calendar.MINUTE);
		Integer second=calendar.get(Calendar.SECOND);
		String years=year.toString();
		String months=month.toString();
		String dates=date.toString();
		String hours=hour.toString();
		String minutes=minute.toString();
		String seconds=second.toString();
//		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//		String time=format.format(new Date());
		months=(month<10)?("0"+months):months;
		dates=(date<10)?("0"+dates):dates;
		hours=(hour<10)?("0"+hours):hours;
		minutes=(minute<10)?("0"+minutes):minutes;
		seconds=(second<10)?("0"+seconds):seconds;
		String time=years+"-"+months+"-"+dates+" "+hours+":"+minutes+":"+seconds;
		System.out.println(time);
		return time;
	}
}
